cmake_minimum_required(VERSION 3.5)
project(triangle_counting)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(VERBOSE "verbose std::cout" OFF)
option(TIMECOUNTING "counting the time used" OFF)
option(ENABLETESTING "enable unit test" OFF)
option(OPENMP "use OPENMP" OFF)
option(CODE_COVERAGE "Enable coverage reporting" OFF)

if(VERBOSE)
    add_definitions("-DVERBOSE=1")
endif()
if(TIMECOUNTING)
    add_definitions("-DTIMECOUNTING=1")
endif()
if(OPENMP)
    find_package(OpenMP REQUIRED)
    add_definitions("-DOPENMP=1")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
add_library(utility io.cpp)
add_library(algorithm counting.cpp)
if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
    target_compile_options(utility PRIVATE --coverage)
    target_compile_options(algorithm PRIVATE --coverage)
    target_link_libraries(algorithm INTERFACE --coverage)
endif()
if(ENABLE_TESTING)
  include(CTest)
  find_package(GTest REQUIRED)
  find_package(Threads REQUIRED)
  add_executable(test_alg test.cpp)
  target_link_libraries(test_alg utility algorithm ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} Threads::Threads) 
  add_test(NAME test_alg COMMAND test_alg)
endif()
add_executable(competition competition.cpp)
target_link_libraries(competition utility algorithm)
